package br.ufpe.cin.rdfilter.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JButton;

import br.ufpe.cin.rdfilter.model.Manager;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class FrameQuery extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextArea textArea;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					FrameQuery frame = new FrameQuery();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public FrameQuery() {
		setTitle("Create a New Query");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 536, 466);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblLabel = new JLabel("Label");
		lblLabel.setBounds(25, 24, 46, 14);
		contentPane.add(lblLabel);
		
		textField = new JTextField();
		textField.setBounds(114, 21, 212, 20);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel lblDescription = new JLabel("Description");
		lblDescription.setBounds(25, 52, 79, 14);
		contentPane.add(lblDescription);
		
		textField_1 = new JTextField();
		textField_1.setBounds(114, 49, 212, 20);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel lblStatement = new JLabel("Statement");
		lblStatement.setBounds(25, 77, 63, 14);
		contentPane.add(lblStatement);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(25, 102, 485, 281);
		contentPane.add(scrollPane);
		
		textArea = new JTextArea();
		scrollPane.setViewportView(textArea);
		
		JButton btnCadastrar = new JButton("Cadastrar");
		btnCadastrar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Manager m = new Manager();
				m.addQuery(textField.getText(), textField_1.getText(), textArea.getText());
			}
		});
		btnCadastrar.setBounds(127, 394, 100, 23);
		contentPane.add(btnCadastrar);
		
		JButton btnCancelar = new JButton("Cancelar");
		btnCancelar.setBounds(237, 394, 89, 23);
		contentPane.add(btnCancelar);
	}
}
